<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body><span>字符串 (1 2 3)</span>
<input type="text" value="1,2" id="text1">&nbsp;
<input type="button" value="开始查找" onclick="chaZhao()">
<span>数组中的偶数有</span>
<input type="text" id="text2">&nbsp;

</body>

<script>
    var elementById1 = document.getElementById("text1");
    var elementById2 = document.getElementById("text2");

    function chaZhao() {
        var arr = elementById1.value.split(",");

        var str = "";
        for (var i = 0; i < arr.length; i++) {

            if (parseInt(arr[i]) % 2 == 0) {
                str += arr[i] + " ";
            }
        }

        elementById2.value = str;

    }
</script>
</html>